<?php
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010-2011 GioCMS (http://cms.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @author		NinhGio - ninhgio@gmail.com
 * @since		1.0
 */

class Modules_Ad_Controllers_Track extends Gio_Core_Controller
{
	/* ========== Frontend actions ========================================== */
	
	/**
	 * Redirect to destination page after clicking on banner
	 * 
	 * @return void
	 */
	public function redirectAction() 
	{
		$this->setNoRender();
		$this->disableLayout();
		
		$request = $this->getRequest();
//		$track   = array(
//						'banner_id'    => $request->getParam('bannerId'),
//						'zone_id' 	   => $request->getParam('zoneId'),
//						'page_id' 	   => $request->getParam('pageId'),
//						'clicked_date' => date('Y-m-d H:i:s'),
//						'ip' 		   => $request->getClientIp(),
//						'from_url' 	   => $request->getServer('HTTP_REFERER'),
//		);
		//Ad_Services_Track::add($track);

		/**
		 * Use javascript redirect to support link that have format mailto
		 */
		$clickUrl = $request->getParam('clickUrl');
		$clickUrl = htmlspecialchars_decode($clickUrl);
		$response = '<script type="text/javascript">window.location="' . addslashes($clickUrl) . '"</script>';
		$this->getResponse()->setBody($response);
	}
}
